{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
 
    <title>Login - Infinite Remote</title>
        <link rel="stylesheet" href="{% static 'layui/css/layui.css' %}">
        <link rel="stylesheet" href="{% static 'layui/css/style.css' %}">

 
</head>
<body>
 
<div class="login-main">
    <header class="layui-elip">Login</header>
    <form class="layui-form">
        <div class="layui-input-inline">
            <input type="text" name="account" required lay-verify="required" placeholder="Username" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" placeholder="Password" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline login-btn">
            <button lay-submit lay-filter="login" class="layui-btn">Login</button>
        </div>
        <hr/>
    </form>
</div>
 
 
<script src={% static "layui/layui.js" %}></script>
<script type="text/javascript">
    layui.use(['form','layer','jquery'], function () {
 
        // Operation objects
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(login)',function (data) {
            console.log(data.field);
            $.ajax({
                url:'/api/user_action?action=login',
                data:data.field,
                dataType:'json',
                type:'post',

                success: function(resp) {
		    			if(resp.code==1) {
		    				//layer.alert(resp.msg,{icon:1});
                            location.href = resp.url;
		    			} else {
		    				layer.alert(resp.msg,{icon:5});
		    			}
                }
            })
            return false;
        })
        $('.fr').on('click', function(){
            layer.alert("For something this simple, isn't the 'Forgot Password' feature unnecessary?",{icon:5});
        })

 
    });
</script>
</body>
</html>
